import QtQuick 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.0

Item {
	property var item
	signal itemSelected(var data)

	id: root

	Layout.fillHeight: true

	ListView {
		id: listView
		width: parent.width
		height: parent.height
		model: item.items
		ScrollBar.vertical: ScrollBar {
			parent: listView.parent
			policy: ScrollBar.AlwaysOn
			anchors.top: listView.top
			anchors.right: listView.right
			anchors.bottom: listView.bottom
		}
		delegate: ItemDelegate {
			width: parent.width
			RowLayout {
				height: parent.height
				width: parent.width
				anchors.fill: parent
				Item { Layout.preferredWidth: 8 }
				Label {
					font.pointSize: 12
					verticalAlignment: Text.AlignVCenter
					text: modelData.title
				}
				Item { Layout.fillWidth: true }
			}
			onClicked: {
				root.itemSelected(modelData);
			}
		}
	}
}
